/**
 * 
 */
package com.geezdata.cps.ttk_admin.api.controller;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.geezdata.cps.base.annotation.LoggerOut;
import com.geezdata.cps.base.response.BaseResponse;
import com.geezdata.cps.cqrs.command.Command;
import com.geezdata.cps.cqrs.command.bus.CommandBus;
import com.geezdata.cps.ttk.common.request.CreateOrUpdateTaskRequest;
import com.geezdata.cps.ttk.common.response.CreateOrUpdateTaskResult;

/**
 * @author zheng
 *
 */
@RestController
@RequestMapping(value="/task")
public class TaskController {
	@Autowired
	private CommandBus commandBus;
	@Autowired
	private Command<CreateOrUpdateTaskRequest, CreateOrUpdateTaskResult> createOrUpdateTaskCommand;
	
	@LoggerOut
    @RequestMapping(value = "/createOrUpdateTask", method = RequestMethod.POST)
    public BaseResponse<CreateOrUpdateTaskResult> createOrUpdateTask(@Valid @RequestBody CreateOrUpdateTaskRequest request) {
		return commandBus.dispatch(createOrUpdateTaskCommand, request);
    }
}
